<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "gas".
 *
 * @property int $id
 * @property int $t_id
 * @property int $tem
 * @property int $hum
 * @property int $gas
 * @property string $time
 *
 * @property Toilet $t
 */
class Gas extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'gas';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['t_id', 'tem', 'hum', 'gas'], 'required'],
            [['t_id', 'tem', 'hum', 'gas'], 'integer'],
            [['time'], 'safe'],
            [['t_id'], 'exist', 'skipOnError' => true, 'targetClass' => Toilet::className(), 'targetAttribute' => ['t_id' => 't_id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            't_id' => 'T ID',
            'tem' => 'Tem',
            'hum' => 'Hum',
            'gas' => 'Gas',
            'time' => 'Time',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getT()
    {
        return $this->hasOne(Toilet::className(), ['t_id' => 't_id']);
    }
}
